﻿/* Write a method GetMax() with two parameters that returns the bigger of two integers. 
 * Write a program that reads 3 integers from the console and prints the biggest of them using the method GetMax().
 */




using System;

class GetMax_
{
    static void Main()
    {
        int firstnumber, secondnumber;
        bool iProvided = false;
        do {
            if (iProvided == true) Console.WriteLine("Error!: Invalid input. Please enter an integer. \r\nValid range: {0} - {1}", Int32.MinValue, Int32.MaxValue);
            else iProvided = true;
            Console.Write("Enter first number: ");
        } while (Int32.TryParse(Console.ReadLine(), out firstnumber) == false);

        //reset iProvided to avoid getting again the error message from a previous error check
        iProvided = false;
        do {
            if (iProvided == true) Console.WriteLine("Error!: Invalid input. Please enter an integer. \r\nValid range: {0} - {1}", Int32.MinValue, Int32.MaxValue);
            else iProvided = true;
            Console.Write("Enter second number: ");
        } while (Int32.TryParse(Console.ReadLine(), out secondnumber) == false);

        int bigger = GetMax(firstnumber, secondnumber);
        Console.WriteLine("The bigger number from the comparsion of {0} and {1} is {2}", firstnumber, secondnumber, bigger);
    }
    private static int GetMax(int a, int b)
    {
        if (a > b) return a;
        else return b;
    }
}
